package com.youyi.yyviewsdklibrary.Dialog.animator;

import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.view.View;

public class ShadowBgAnimator extends PopupAnimator {
    public ArgbEvaluator argbEvaluator = new ArgbEvaluator();
    public boolean isZeroDuration = false;
    public int shadowColor;
    public int startColor = 0;

    public ShadowBgAnimator(View view, int i, int i2) {
        super(view, i);
        this.shadowColor = i2;
    }

    public ShadowBgAnimator() {
    }

    @Override // com.youyi.yyviewsdklibrary.Dialog.animator.PopupAnimator
    public void initAnimator() {
        this.targetView.setBackgroundColor(this.startColor);
    }

    @Override // com.youyi.yyviewsdklibrary.Dialog.animator.PopupAnimator
    public void animateShow() {
        ValueAnimator ofObject = ValueAnimator.ofObject(this.argbEvaluator, Integer.valueOf(this.startColor), Integer.valueOf(this.shadowColor));
        ofObject.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            /* class com.youyi.yyviewsdklibrary.Dialog.animator.ShadowBgAnimator.AnonymousClass1 */

            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                ShadowBgAnimator.this.targetView.setBackgroundColor(((Integer) valueAnimator.getAnimatedValue()).intValue());
            }
        });
        ofObject.setInterpolator(new FastOutSlowInInterpolator());
        ofObject.setDuration(this.isZeroDuration ? 0 : (long) this.animationDuration).start();
    }

    @Override // com.youyi.yyviewsdklibrary.Dialog.animator.PopupAnimator
    public void animateDismiss() {
        if (!this.animating) {
            ValueAnimator ofObject = ValueAnimator.ofObject(this.argbEvaluator, Integer.valueOf(this.shadowColor), Integer.valueOf(this.startColor));
            ofObject.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                /* class com.youyi.yyviewsdklibrary.Dialog.animator.ShadowBgAnimator.AnonymousClass2 */

                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    ShadowBgAnimator.this.targetView.setBackgroundColor(((Integer) valueAnimator.getAnimatedValue()).intValue());
                }
            });
            observerAnimator(ofObject);
            ofObject.setInterpolator(new FastOutSlowInInterpolator());
            ofObject.setDuration(this.isZeroDuration ? 0 : (long) this.animationDuration).start();
        }
    }

    public void applyColorValue(float f) {
        this.targetView.setBackgroundColor(Integer.valueOf(calculateBgColor(f)).intValue());
    }

    public int calculateBgColor(float f) {
        return ((Integer) this.argbEvaluator.evaluate(f, Integer.valueOf(this.startColor), Integer.valueOf(this.shadowColor))).intValue();
    }
}
